<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<body>
<script type="text/html" id="toolbarDemo1">
	<div class="layui-btn-container">
		<button class="layui-btn layui-btn-sm" lay-event="addxz">新增</button>
  	</div>
</script>
     <fieldset class="layui-elem-field layui-field-title site-title">
			<legend><a name="fixbar" style="font-size: 16px; color: #ce2424;">考核信息</a></legend>
		</fieldset>
		<form class="layui-form" action="save" id="myForm" method="post" lay-filter="stuform">
			<div class="layui-form-item">
			<div class="layui-inline" style="width: 420px;">
					<label class="layui-form-label">班级名称：</label>
					<div class="layui-input-block">
						<select id="bjid" name="bjid" lay-filter="bjselect" lay-verify="required"
							lay-search>
							<c:forEach var="d" items="${data}">
								<option value="${d.id }">${d.name}</option>
							</c:forEach>
						</select>
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label">考核项目：</label>
			<div class="layui-input-inline">
				<input type="text" id="examination" name="examination" value="${param.examination}" class="layui-input" />
			</div>
				</div>
				
<%-- 				<div class="layui-inline">
					<label class="layui-form-label">计分方法：</label>
				<div class="layui-input-inline">
					<input type="text" name="scoringmethod" value="${param.scoringmethod}" class="layui-input" />
				</div>
				</div> --%>
				<div class="layui-inline">
					<button type="button" class="layui-btn layui-btn-danger" onclick="search()" >查询</button>
					<button type="button" class="layui-btn layui-btn-danger" onclick="empty()" >清空</button>
				</div>
			</div>
		</form>
     


<table class="layui-hide" id="assessmentInformation" lay-filter="assessmentInformation"></table>
<script type="text/javascript">

layui.use('form', function() {
	var form = layui.form;
	form.render();

	form.on('select(bjselect)', function(data) {
		var bjuuid = data.value;
		layui.use('table', function() {
			var table = layui.table;
			table.reload('idTest', {
				url : 'assessmentInformation/page',
				where : {
					tbClassid : bjuuid
				},
				page : {
					curr : 1
				//重新从第 1 页开始
				}
			});
		});
	});
});
        var bjid = $('#bjid').val();
		var option={
			elem:'#assessmentInformation',
			id:'idTest',
			title:'考核信息',
			path:'assessmentInformation',
			addurl:'edit',
			height:'full-265',
			toolbar:'#toolbarDemo1',
			where:{examination:'${param.examination}',tbClassid:bjid},
			cols: [[
				{field: 'id', title: 'ID', hide: true, usersize: true, sort: true},
				{field: 'examination', title: '考核项目'},
				{field: 'score', title: '分值'},
				{field: 'scoringmethod', title: '计分方法'},
				{field: 'explain', title: '说明'},
				{field: 'quantitative', title: '量化细则'},
				{field: 'designformulas', title: '计算公式'},
				{field: 'finishtime', title: '完成时间'},
				{fixed: 'right', title:'操作', toolbar: '#barDemo2', width:200}
			]] 
		}
		var currRow="${param.currRow==null?'null':param.currRow}";
		var limit=${param.limit==null?'null':param.limit};
		var page=${param.page==null?'null':param.page};
		var classTable=new LayUiTable(option,currRow,limit,page);
		classTable.init();
		
		function search(){
			classTable.search();
		}

		layui.use('table', function() {
			var table = layui.table;
			table.on('toolbar(assessmentInformation)', function(obj) {
				var checkStatus = table.checkStatus(obj.config.id);
				if (obj.event === "addxz") {
					var bjid = $('#bjid').val();
					var examination = $('#examination').val();
					var limit=${param.limit==null?'null':param.limit};
					var page=${param.page==null?'null':param.page};
					var subDiv=$('<div class="layui-form-item" style="text-align: right;"><button class="layui-btn" lay-submit lay-filter="formVerify">立即提交</button><button type="reset" class="layui-btn layui-btn-primary">重置</button><button id="closeBtn" type="button" class="layui-btn layui-btn-primary">返回</button></div>');
					$.get("assessmentInformation/edit",{tbClassid:bjid},function(data){
						//data.append(subDiv);
						$('#content').html(data);
						$('#content').find('form').append(subDiv);
						$('#closeBtn').click(function(){
							$('#content').load('assessmentInformation/manage?limit='+limit+'&page='+page,{
								tbClassid : bjid,
								examination:examination
							});
						});
						layui.use('form',function(){
							var form=layui.form;
							
							form.on('submit(formVerify)',function(data){
								$.post("assessmentInformation/save",data.field,function(result){
									if(result.success){
										$('#content').load('assessmentInformation/manage?limit='+limit+'&page='+page);
									}else{
										layer.msg(result.msg,{offset:'rb'});
									}
								});
								return false;
							});
						});
						
					});
				}
			});
		});
		
		
		function empty(){
			var bjuuid = $('#bjid').val();
			$('#examination').val('');
			layui.use('table', function() {
				var table = layui.table;
				table.reload('idTest', {
					url : 'assessmentInformation/page',
					where : {
						tbClassid : bjuuid,
						examination:''
					},
					page : {
						curr : 1
					//重新从第 1 页开始
					}
				});
			});
		}
	</script>											
</body>
